/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ConsultasProducciones;

import Conexion.Conexion;
import java.sql.*;
/**
 *
 * @author GJ_ASPRILLA
 */
public class ProdAgricola {
private static Conexion conn = Conexion.getInstance();
    public static void main(String[] args) {
        try {
            
            Statement statement;
            ResultSet rs;
            statement = conn.getConection().createStatement();
            
            String QueryString = "SELECT [anho_EVA] ,[codigoAgronetCultivo_EVA] ,[codigoDepartamento_EVA] ,[area_EVA] ,[produccion_EVA] ,nombreDescriptorCultivo FROM [AgronetEVA].[dbo].[EVADepartamental], EVAProductos where codigoAgronetCultivo_EVA=codigoAgronetCultivo";
            rs = statement.executeQuery(QueryString);
            System.out.println(rs);
            System.out.println("anho_EVA    codigoAgronetCultivo_EVA   codigoDepartamento_EVA      area_EVA         produccion_EVA    nombreDescriptorCultivo");
            int count = 0;
            while (rs.next()) { 
                System.out.println(rs.getInt(1) + "         " + rs.getString(2) + "                " + rs.getString(3) + "               " + rs.getString(4) + "             " + rs.getString(5) + "             " + rs.getString(6));
                count=++count;
                System.out.print(count);
            }
        } catch (Exception ex) {
            System.out.println("Unable to connect to batabase.");
        }
    }
}
